package com.kcht.itsed.mws.persist.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kcht.itsed.mws.alemodel.ECSpec;
import com.kcht.itsed.mws.extendalemodel.PRSpec;
import com.kcht.itsed.mws.extendmodel.jpa.PhysicalReaderEntity;
import com.kcht.itsed.mws.extendmodel.jpa.SpecEntityConverter;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;

import java.util.List;
import java.util.Optional;

/**
 * Created by God on 2016/4/20.
 */
public interface IPhysicalReaderDao extends BaseMapper<PhysicalReaderEntity> {

    @Select("select * from T_PHYSICAL_READER where READER_NAME=#{name}")
    @Results(
            @Result(
                    column = "PR_SPEC",
                    property = "prSpec",
                    javaType = PRSpec.class,
                    jdbcType = JdbcType.VARCHAR,
                    typeHandler = SpecEntityConverter.class
            )
    )
    Optional<PhysicalReaderEntity> findByName(String name);

    @Select("select * from T_PHYSICAL_READER")
    @Results(
            @Result(
                    column = "PR_SPEC",
                    property = "prSpec",
                    javaType = PRSpec.class,
                    jdbcType = JdbcType.VARCHAR,
                    typeHandler = SpecEntityConverter.class
            )
    )
	List<PhysicalReaderEntity> getAllPRs();
}
